<?php
/**
 * Created by PhpStorm.
 * User: yf
 * Date: 2016/8/11
 * Time: 14:01
 */
namespace YMApi\Model;
use Think\Model;

class RegionModel extends Model
{
    protected $tableName = 'region';
    
    
    
  /**
     * 获得指定国家的所有省份
     * @param type $type
     * @param type $parent
     * @return type
     */
    public function get_regions($parent = 0,$type = 0) {
        $where['region_type'] = $type;
        $where['parent_id'] = $parent;
        $res=$this->where($where)->select();
        if($res){
        	return array('regionlist'=>$res);
        }else{
        	return false;
        }
    }
    
    /*根据区域ID获取详细*/
    public function get_regionname($region_id){
    	$res=$this->where(array('region_id'=>$region_id))->find();
        if($res){
        	return array($res);
        }else{
        	return false;
        }
    }
    
}